/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kasus.view;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import kasus.model.Mahasiswa;

/**
 *
 * @author mei
 */
public class PublikasiTableModel extends AbstractTableModel {

    String columNames[] = {"NIM", "NAMA", "NOHP"};
    private ArrayList<Mahasiswa> data;

    public PublikasiTableModel() {
    }

    public PublikasiTableModel(ArrayList<Mahasiswa> data) {
        this.data = data;
    }

    public int getRowCount() {
        return getData().size();
    }

    public int getColumnCount() {
        return columNames.length;
    }

    @Override
    public String getColumnName(int col) {
        return columNames[col];
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Mahasiswa temp = getData().get(rowIndex);
        if (columnIndex == 0) {
            return temp.getNim();
        } else if (columnIndex == 1) {
            return temp.getNama();
        } else  {
            return temp.getNomor_hp();
        }
    }

    public ArrayList<Mahasiswa> getData() {
        return data;
    }

    public void setData(ArrayList<Mahasiswa> data) {
        this.data = data;
    }
}
